package com.hong.spring.contoller;

import com.hong.spring.grpc.HelloWorldClient;
import com.hong.spring.utils.DataResponse;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: csh
 * @Date: 2020/8/18 16:11
 * @Description:
 */
@RestController
@RequestMapping("/")
@Log4j2
public class UserController {

    @Autowired
    private HelloWorldClient client;


    @RequestMapping(value = "allUser",method = RequestMethod.GET)
    @ResponseBody
    public DataResponse<Boolean> sendMsg(String msg){
        try {
            String reply = client.sayHello("");
            return DataResponse.BuildSuccessResponse(reply);
        }catch (Exception e){
            log.error("发送出错!{}",e);
        }
        return DataResponse.BuildFailResponse("发送出错！");
    }
}
